export const regexp = {
  isChinese: (str) => /^[\u2E80-\u9FFF]{2,4}$/g.test(str),
  isEmail: (str) => /^([a-z0-9_.-]+)@([\da-z.-]+)\.([a-z.]{2,6})$/g.test(str),
  isBankNumber: (str) =>
    /^([1-9]{1})(\d{15}|\d{18})$/.test(str.replace(/\s+/g, "")),
  idCard: (str) => /^(\d{15}$)|(^\d{17}([0-9]|X))$/.test(str),
  isNumber: (str) => /^[1-9]\d*$/.test(str),
  isPostalCode: (str) => /^[1-9][0-9]{5}$/.test(str),
  isEmpty: (el) => !!el.trim(),
  isInternalPhone: (str) => /^(?:(?:\+|00)86)?1[3-9]\d{9}$/.test(str), // 国内手机 包含大陆/台湾/香港/澳门
  isHttp: (str) => /(http|https):\/\/([\w.]+\/?)\S*/.test(str),
  isBase64: (str) =>
    /^\s*data:(?:[a-z]+\/[a-z0-9-+.]+(?:;[a-z-]+=[a-z0-9-]+)?)?(?:;base64)?,([a-z0-9!$&',()*+;=\-._~:@/?%\s]*?)\s*$/i.test(
      str
    ),
  isPx: (str) => /px/.test(str) && str.endsWith("px"),
  isRem: (str) => /rem/.test(str) && str.endsWith("rem"),
  isEm: (str) =>
    /em/.test(str) &&
    !(/rem/.test(str) && str.endsWith("rem")) &&
    str.endsWith("em"),
  isVw: (str) => /vw/.test(str) && str.endsWith("vw"),
  isVh: (str) => /vh/.test(str) && str.endsWith("vh"),
  isPercent: (str) => /%/.test(str) && str.endsWith("%"),
};
